package com.test.httpclient;

import org.json.JSONException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by yang on 17/3/7.
 */
public class StuLogin {

    public static List<String> token = new ArrayList<String>();

    public static void getToken() throws IOException, JSONException {

        Phone.getPhone();
//        String url = "http://stuapi.knowbox.cn/user/auth/login";
        String url = "http://qa.knowbox.cn:8002/user/auth/login";
//        String baseJson = "{\"source\":\"androidRCStudent\",\"version\":3.0.0,\"channel\":\"Knowbox\",\"deviceId\":\"867323021373194\",\"deviceVersion\":\"6.0.1\",\"deviceType\":\"MI_4LTE\",\"token\":\"\",\"transaction\":\"login\",\"loginName\":\"18610790001\",\"password\":\"15300085107\",\"deviceToken\":\"\"}";
//        JSONObject jsonObject = new JSONObject(baseJson);

        for (int i = 0; i < Phone.phones.size(); i ++) {
//            jsonObject.put("loginName", Basic.phones.get(i));
            Map<String, String> loginJson = new HashMap<String, String>();
            loginJson.put("source", "iPhoneRCStudent");
            loginJson.put("loginName", Phone.phones.get(i));
            loginJson.put("password", "15300085107");
            loginJson.put("deviceType", "iPhone6");
            loginJson.put("transaction", "login");
            loginJson.put("version", "3.0.0");
            loginJson.put("deviceModel", "iPhone");
            System.out.println(loginJson);
            String response = Post.sendPost(url, loginJson);
            System.out.println(response);
//            String out = Post.dataValue(response);
//            token.add(out);
        }
        System.out.println(token);
    }

    public static void main(String[] args) throws IOException, JSONException {
        try {
            StuLogin.getToken();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}